//
//  DHIsFinishedCell.m
//  精品酒店
//
//  Created by DIANGHONG on 2018/5/10.
//  Copyright © 2018年 DIANGHONG. All rights reserved.
//

#import "DHMyPostTaskCell.h"
@interface DHMyPostTaskCell()
@property (weak, nonatomic) IBOutlet UILabel *orderNumLabel;
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *orderLabel;
@property (weak, nonatomic) IBOutlet UILabel *isFinishedLabel;
@property (weak, nonatomic) IBOutlet UILabel *endTimeLabel;
@property (weak, nonatomic) IBOutlet UIButton *locButton;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UIButton *commentButton;
@property (weak, nonatomic) IBOutlet UIButton *isFinishButton;


@end

@implementation DHMyPostTaskCell


- (void)setModel:(DHCleanOrderModel *)model
{
    _model = model;
    
    self.orderNumLabel.text = model.order_id;
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.logo]];
    self.orderLabel.text = model.title;
    self.isFinishedLabel.text = model.type;
    self.endTimeLabel.text = model.end_time;
    self.priceLabel.text = [NSString stringWithFormat:@"%@元",model.price];

    NSString *isFinished = (model.status.intValue == 2) ? @"已完成" : @"进行中";
   // NSString *isEvaStr;
    if ([model.pay_status isEqualToString:@"0"]) { // 是否支付
        // isEvaStr =;
        [self.commentButton setTitle:@"去支付" forState:UIControlStateNormal];
    }else{
        if ([model.status isEqualToString:@"0"])
        {
       
        self.commentButton.hidden = NO;
        [self.commentButton setTitle:@"编辑" forState:UIControlStateNormal];
            
        }else if ([model.status isEqualToString:@"1"]) // 进行中
        {
            self.commentButton.hidden = NO;
            [self.commentButton setTitle:@"确认完成" forState:UIControlStateNormal];
            
        }else if ([model.status isEqualToString:@"3"]){ // 商户
            
            if (model.evaluate_status.boolValue) {
                
                self.commentButton.hidden = NO;
                [self.commentButton setTitle:@"去评价" forState:UIControlStateNormal];
            }else{
                     self.commentButton.hidden = YES;
            }
            
            
    }
    
    }

    [self.isFinishButton setTitle:isFinished forState:UIControlStateNormal];

   // self.commentButton.hidden = !model.evaluate_status.boolValue;
    //[self.commentButton setTitle:isEvaStr forState:UIControlStateNormal];

    [self.locButton setTitle:[NSString stringWithFormat:@"%@.%@",model.area,model.city] forState:UIControlStateNormal];
}

- (void)awakeFromNib {
    [super awakeFromNib];

   
}
#pragma mark: - 评价按钮点击监听
- (IBAction)btnGoCommectClick:(UIButton *)sender
{
    if (self.model.pay_status.boolValue) {
        [self.delegate finishedCellPayDone:self model:self.model];
    }else{
        [self.delegate finishedCellNonePay:self model:self.model];
    }
}

@end
